﻿using System;

namespace Communication.Message.Buffer
{
	// Token: 0x0200000B RID: 11
	internal abstract class HeapMessageBuffer : AbstractMessageBuffer
	{
		// Token: 0x06000084 RID: 132 RVA: 0x00002633 File Offset: 0x00000833
		public HeapMessageBuffer(int length) : this(new byte[length], 0, 0)
		{
		}

		// Token: 0x06000085 RID: 133 RVA: 0x00002643 File Offset: 0x00000843
		public HeapMessageBuffer(byte[] array) : this(array, 0, array.Length)
		{
		}

		// Token: 0x06000086 RID: 134 RVA: 0x00002650 File Offset: 0x00000850
		protected HeapMessageBuffer(byte[] array, int readerIndex, int writerIndex)
		{
			if (array == null)
			{
				throw new ArgumentNullException("array");
			}
			this.array = array;
			base.SetIndex(readerIndex, writerIndex);
		}

		// Token: 0x06000087 RID: 135 RVA: 0x00002675 File Offset: 0x00000875
		public override int Capacity()
		{
			return this.array.Length;
		}

		// Token: 0x06000088 RID: 136 RVA: 0x0000267F File Offset: 0x0000087F
		public override byte GetByte(int index)
		{
			if (index < 0 || index >= this.array.Length)
			{
				throw new ArgumentNullException();
			}
			return this.array[index];
		}

		// Token: 0x06000089 RID: 137 RVA: 0x0000269E File Offset: 0x0000089E
		public override void SetByte(int index, byte b)
		{
			this.array[index] = b;
		}

		// Token: 0x0600008A RID: 138 RVA: 0x000026A9 File Offset: 0x000008A9
		public override void GetBytes(int index, byte[] dst, int dstIndex, int length)
		{
			System.Array.Copy(this.array, index, dst, dstIndex, length);
		}

		// Token: 0x0600008B RID: 139 RVA: 0x000026BB File Offset: 0x000008BB
		public override void SetBytes(int index, byte[] src, int srcIndex, int length)
		{
			System.Array.Copy(src, srcIndex, this.array, index, length);
		}

		// Token: 0x0600008C RID: 140 RVA: 0x000026CD File Offset: 0x000008CD
		public override void SetBytes(int index, MessageBuffer src, int srcIndex, int length)
		{
			if (src is HeapMessageBuffer)
			{
				this.SetBytes(index, ((HeapMessageBuffer)src).array, srcIndex, length);
				return;
			}
			src.GetBytes(srcIndex, this.array, index, length);
		}

		// Token: 0x0600008D RID: 141 RVA: 0x000026FD File Offset: 0x000008FD
		public override byte[] Array()
		{
			return this.array;
		}

		// Token: 0x04000007 RID: 7
		protected readonly byte[] array;
	}
}
